package com.app.micaihu.bean.news;


import android.text.TextUtils;

import com.app.micaihu.app.AppApplication;
import com.app.micaihu.bean.ad.NativeAd;
import com.app.micaihu.bean.game.IDownload;
import com.app.micaihu.bean.speak.ILaud;
import com.app.micaihu.configure.AppConfigTools;
import com.app.micaihu.configure.TypeConstant;
import com.app.micaihu.custom.components.downandupload.DownloadUtils;
import com.app.utils.util.AppTools;
import com.app.utils.util.StringUtils;

import java.io.Serializable;
import java.util.List;

/**
 * 新闻列表实体
 *
 * @author linkai
 */
public class NewsEntity extends ShareBean implements IDownload, ILaud, Serializable {


    private String articleAttr;//文章属性（1置顶 2热门 3推荐 4首发 5独家 6VIP稿子 7原创）
    private String articleMark;//小标地址
    private String articleSummary;//文章简述
    private String[] articleThumb;//图集
    private String picNum;//图片数量
    private String articleTime;//发布时间
    private String articleTitle;//文章标题
    //文章类型(1.普通文章、2.普通图集、3普通视频 4.电商文章 5.网页文章 6.电商网页软文 7.网页视频 8.轻专题 9.广告)
    private String articleType;//文章类型
    private String commentNum;//评论总数
    private String uiType;//展示类型(0小图 1大图)
    private String praiseNum;//点赞数
    private String categoryId;//文章栏目id
    private String isPraise;//是否点赞过
    private String urlStatus;//视频链接分类 1：外链视频 2：云视频 3：两者都有
    private String authorRankName;//作者军衔名称
    private String authorRankIcon;//作者军衔图片
    private String jumpUrl;//跳转地址
    private String videoUrl;//播放url 网页地址
    private String videoCurl;//腾讯云视频url MP4地址
    private String labelIcon;//视频标签
    private String attrIcon;//属性图片 如最新
    private String clickNum;//点击量
    private String period;//所属期数
    private int adPosition;//位置坐标(此属性可以指定位置)
    private String packageName;//游戏包名(用于游戏文章稿子)
    private String appSize;//文件大小
    private String appName;//app名字
    private String gameId;//游戏id
    private String isInstall;//是否安装游戏 0 已安装  非0未安装
    private String playTime;//视频时长
    private String showPlayBtn;//是否展示播放按钮  是否显示播放按钮 1是 0否
    private NativeAd nativeAd;//包含的广告
    private String serialId;//文章在后台的位置ID
    private String showType;//是否是要闻->决定推送是否弹窗
    private String iTag;//用于下载按钮的
    private String appIcon;//下载APP的logo

    private String slogan;//游戏描述


    private String table_id;// 浏览历史 数据库id

    private GameInfo gameInfo;
    private boolean threeSecondDisplay;// 知识列表 视频播放3秒显示游戏介绍

    private String honourPic;
    private String armyGroupInfo;
    private int status;//4的时候 已下架

    public void setStatus(int status) {
        this.status = status;
    }
    public String getHonourPic() {
        return honourPic;
    }

    public void setHonourPic(String honourPic) {
        this.honourPic = honourPic;
    }

    public String getArmyGroupInfo() {
        return armyGroupInfo;
    }

    public void setArmyGroupInfo(String armyGroupInfo) {
        this.armyGroupInfo = armyGroupInfo;
    }

    public boolean isThreeSecondDisplay() {
        return threeSecondDisplay;
    }

    public void setThreeSecondDisplay(boolean threeSecondDisplay) {
        this.threeSecondDisplay = threeSecondDisplay;
    }

    public GameInfo getGameInfo() {
        return gameInfo;
    }

    public void setGameInfo(GameInfo gameInfo) {
        this.gameInfo = gameInfo;
    }

    public static class GameInfo implements Serializable {

        /**
         * id : 278583833280613004
         * title : 115：银河战舰
         * appIcon : http://img1.micaiying.com/game/0_2018/01/23/1827241887.jpg
         * gradeScore : 9.3
         * appType : ["星际","科幻","策略"]
         */

        private String id;
        private String title;
        private String appIcon;
        private String gradeScore;
        private List<String> appType;


        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getAppIcon() {
            return appIcon;
        }

        public void setAppIcon(String appIcon) {
            this.appIcon = appIcon;
        }

        public String getGradeScore() {
            return gradeScore;
        }

        public void setGradeScore(String gradeScore) {
            this.gradeScore = gradeScore;
        }

        public List<String> getAppType() {
            return appType;
        }

        public void setAppType(List<String> appType) {
            this.appType = appType;
        }
    }

    public String getTable_id() {
        return table_id;
    }

    public void setTable_id(String table_id) {
        this.table_id = table_id;
    }

    public String getSlogan() {
        return slogan;
    }

    public void setSlogan(String slogan) {
        this.slogan = slogan;
    }

    public String getAppIcon() {
        return appIcon;
    }

    public void setAppIcon(String appIcon) {
        this.appIcon = appIcon;
    }

    public String getShowType() {
        return showType;
    }

    public void setShowType(String showType) {
        this.showType = showType;
    }


    public String getArticleAttr() {
        return articleAttr;
    }

    public void setArticleAttr(String articleAttr) {
        this.articleAttr = articleAttr;
    }

    public String getArticleMark() {
        return articleMark;
    }

    public void setArticleMark(String articleMark) {
        this.articleMark = articleMark;
    }

    public String getArticleSummary() {
        return articleSummary;
    }

    public void setArticleSummary(String articleSummary) {
        this.articleSummary = articleSummary;
    }

    public String[] getArticleThumb() {
        return articleThumb;
    }

    public void setArticleThumb(String[] articleThumb) {
        this.articleThumb = articleThumb;
    }

    public String getPicNum() {
        return picNum;
    }

    public void setPicNum(String picNum) {
        this.picNum = picNum;
    }

    public String getArticleTime() {
        return articleTime;
    }

    public void setArticleTime(String articleTime) {
        this.articleTime = articleTime;
    }

    public String getArticleTitle() {
        return articleTitle;
    }

    public void setArticleTitle(String articleTitle) {
        this.articleTitle = articleTitle;
    }

    public String getArticleType() {
        return articleType == null ? "" : articleType;
    }

    public void setArticleType(String articleType) {
        this.articleType = articleType;
    }

    public String getCommentNum() {
        return commentNum;
    }

    public void setCommentNum(String commentNum) {
        this.commentNum = commentNum;
    }

    public String getUiType() {
        return uiType;
    }

    public void setUiType(String uiType) {
        this.uiType = uiType;
    }

    public String getPraiseNum() {
        return praiseNum;
    }

    public void setPraiseNum(String praiseNum) {
        this.praiseNum = praiseNum;
    }

    public String getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(String categoryId) {
        this.categoryId = categoryId;
    }

    public String getIsPraise() {
        return isPraise;
    }

    public void setIsPraise(String isPraise) {
        this.isPraise = isPraise;
    }

    public boolean IsPraise() {
        if ("0".equals(isPraise)) {
            return false;
        }
        return true;
    }

    public String getUrlStatus() {
        return urlStatus;
    }

    public void setUrlStatus(String urlStatus) {
        this.urlStatus = urlStatus;
    }

    public String getAuthorRankName() {
        return authorRankName;
    }

    public void setAuthorRankName(String authorRankName) {
        this.authorRankName = authorRankName;
    }

    public String getAuthorRankIcon() {
        return authorRankIcon;
    }

    public void setAuthorRankIcon(String authorRankIcon) {
        this.authorRankIcon = authorRankIcon;
    }

    public NativeAd getNativeAd() {
        return nativeAd;
    }

    public void setNativeAd(NativeAd nativeAd) {
        this.nativeAd = nativeAd;
    }

    public String getJumpUrl() {
        return jumpUrl;
    }

    public void setJumpUrl(String jumpUrl) {
        this.jumpUrl = jumpUrl;
    }

    public String getVideoUrl() {
        return videoUrl;
    }

    public void setVideoUrl(String videoUrl) {
        this.videoUrl = videoUrl;
    }

    public String getVideoCurl() {
        return videoCurl;
    }

    public void setVideoCurl(String videoCurl) {
        this.videoCurl = videoCurl;
    }

    public String getLabelIcon() {
        return labelIcon;
    }

    public void setLabelIcon(String labelIcon) {
        this.labelIcon = labelIcon;
    }

    public String getAttrIcon() {
        return attrIcon;
    }

    public void setAttrIcon(String attrIcon) {
        this.attrIcon = attrIcon;
    }

    public String getClickNum() {
        return clickNum;
    }

    public void setClickNum(String clickNum) {
        this.clickNum = clickNum;
    }

    public String getPeriod() {
        return period;
    }

    public void setPeriod(String period) {
        this.period = period;
    }

    public int getAdPosition() {
        return adPosition;
    }

    public void setAdPosition(int adPosition) {
        this.adPosition = adPosition;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public String getAppSize() {
        return appSize;
    }

    public void setAppSize(String appSize) {
        this.appSize = appSize;
    }

    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    public String getGameId() {
        return gameId;
    }

    public void setGameId(String gameId) {
        this.gameId = gameId;
    }

    public String getPlayTime() {
        if (TextUtils.equals(playTime, "0")) {
            playTime = "";
        }
        return playTime;
    }

    public void setPlayTime(String playTime) {
        this.playTime = playTime;
    }

    public String getShowPlayBtn() {
        return showPlayBtn;
    }

    public void setShowPlayBtn(String showPlayBtn) {
        this.showPlayBtn = showPlayBtn;
    }

    public String getSerialId() {
        return serialId;
    }

    public void setSerialId(String serialId) {
        this.serialId = serialId;
    }

    /**
     * 获取下载的游戏是否安装
     *
     * @return
     */
    public boolean isinstall() {
        if (AppConfigTools.installValue != 0) {
            //如果有应用安装或卸载 则每次都去获取是否安装
            return AppTools.isAppInstall(AppApplication.getInstance(), packageName);
        }
        if (TextUtils.isEmpty(isInstall)) {
            //如果等于空 说明没有判断过，那么进行判断
            boolean b = AppTools.isAppInstall(AppApplication.getInstance(), packageName);
            if (b) {
                isInstall = "0";
            } else {
                isInstall = "1";
            }
        }
        return TextUtils.equals(isInstall, "0");
    }

    /**
     * 将广告数据转换为新闻
     */
    public void nativeToNews() {
        if (nativeAd == null || !TextUtils.isEmpty(articleTitle)) {
            //如果已经转换过了就不再进行转换
            return;
        }
        this.articleTitle = nativeAd.getTitle();
        this.articleMark = nativeAd.getMark();
        this.articleThumb = nativeAd.getThumbList();
        this.articleSummary = nativeAd.getSummary();
        this.articleId = nativeAd.getAdId();
        this.articleTime = nativeAd.getPublishTime();
        this.serialId = nativeAd.getSerialId();
    }

    @Override
    public String getIUrl() {
        return getJumpUrl();
    }

    @Override
    public String getIPath() {
        return DownloadUtils.FILE_START_NAME + getPackageName();
    }

    @Override
    public String getITitle() {
        return getArticleTitle();
    }

    @Override
    public String getIPackageName() {
        return getPackageName();
    }

    @Override
    public String getITag() {
        if (TextUtils.isEmpty(iTag)) {
            iTag = StringUtils.macthUrl(getIUrl());
        }
        return iTag;
    }

    @Override
    public String getIGameId() {
        return getArticleId();
    }

    @Override
    public String getIAppIcon() {
        return getAppIcon();
    }

    @Override
    public String getIGameSummary() {
        return getSlogan();
    }

    @Override
    public String getISize() {
        return getAppSize();
    }

    @Override
    public int getStatus() {
        return status;
    }


    @Override
    public String getILaudOperateType() {
        return TypeConstant.ZAN_NORMAL;
    }

    @Override
    public String getILaudNum() {
        return getPraiseNum();
    }

    @Override
    public String getILaudType() {
        return "0";
    }

    @Override
    public void setILaudNum(String iLaudNum) {
        setPraiseNum(iLaudNum);
    }

    @Override
    public String getNewsId() {
        return getArticleId();
    }

    @Override
    public String getICommentId() {
        return "";
    }

    @Override
    public String getIParentCmtId() {
        return "";
    }

    @Override
    public String getIType() {
        return null;
    }

    @Override
    public String getIToUid() {
        return getAuthorId();
    }

    @Override
    public void setIToUid(String toUid) {

    }


}
